﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace EscapeFromLenovo
{
    /// <summary>
    /// Enemy sprites.
    /// </summary>
    class Bit
    {
        //BASIC MEMBER VARIABLES
        Texture2D textureImage;
        public Vector2 position;
        protected Point frameSize;
        int collisionOffset;
        Point currentFrame;
        Point sheetSize;

        //SCORING VARIABLES
        public int scoreValue;

        //CONSTRUCTOR
        public Bit(Texture2D textureImage, Vector2 position, Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize, int scoreValue)
        {
            this.textureImage = textureImage;
            this.position = position;
            this.frameSize = frameSize;
            this.collisionOffset = collisionOffset;
            this.currentFrame = currentFrame;
            this.sheetSize = sheetSize;
            this.scoreValue = scoreValue;
        }

        //COLLSION RECTANGLE
        public Rectangle collisionRect
        {
            get
            {
                return new Rectangle((int)position.X + collisionOffset,
                                     (int)position.Y + collisionOffset,
                                     frameSize.X - (collisionOffset * 2),
                                     frameSize.Y - (collisionOffset * 2));
            }
        }

        //UPDATE METHOD: for constant animation
        public void Update(GameTime gameTime, Rectangle clientBounds)
        {

        }

        //DRAW METHOD
        public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(textureImage, position, new Rectangle(currentFrame.X * frameSize.X,
                                                                   currentFrame.Y * frameSize.Y,
                                                                   frameSize.X, frameSize.Y), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0);
        }
    }
}
